/**
 * Ce listner permet de forcer l acréation d'une session avant de rendre la reponse.
 */
package ma.moliere.transverse;

import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;

/**
 * @author sasmami
 * 
 */
public class SessionPhaseListener implements PhaseListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1921193519728302624L;

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.faces.event.PhaseListener#afterPhase(javax.faces.event.PhaseEvent)
	 */
	@Override
	public void afterPhase(final PhaseEvent event) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.faces.event.PhaseListener#beforePhase(javax.faces.event.PhaseEvent)
	 */
	@Override
	public void beforePhase(final PhaseEvent event) {
		// we need to ask for the session early

		FacesContext.getCurrentInstance().getExternalContext().getSession(true);

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.faces.event.PhaseListener#getPhaseId()
	 */
	@Override
	public PhaseId getPhaseId() {
		return PhaseId.RENDER_RESPONSE;
	}

}
